package aex.util;

import java.util.Set;

import aex.domain.ArticleCategory;
import aex.domain.AttentionUser;
import aex.domain.CategoryEditer;
import aex.domain.Puser;

public class Ptool {
	
	/**
	 * 判断用户的集合中是否存在目前传入的小组
	 * 存在返回true
	 * @param set
	 * @param category
	 * @return
	 */
	public static boolean userIsInCategory(Set<CategoryEditer> set,ArticleCategory category){
		boolean flag=false;
		for (CategoryEditer categoryEditer : set) {
			if(categoryEditer.getArticleCategory().getAcId().equals(category.getAcId())){
				flag=true;
				break;
			}
		}
		return flag;
	}
	
	/**
	 * 判断用户是否关注了传入的目标用户
	 * 存在返回true
	 * @param set
	 * @param category
	 * @return
	 */
	public static boolean userIsInAttention(Set<AttentionUser> set,Puser puser){
		boolean flag=false;
		for (AttentionUser at : set) {
			if(at.getPuserByAuAattentiond().getPuId().equals(puser.getPuId())){
				flag=true;
				break;
			}
		}
		return flag;
	}
}
